<?php

if (!defined('TOBBIVM'))
	header('location:/template/notrepassing.php');
/**
 * This file is part of TobbiVMShop.
 *
 * TobbiVMShop is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * TobbiVMShop is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with TobbiVMShop.  If not, see <http://www.gnu.org/licenses/>.
 */

/**
 * Content for Page->Order completion
 * set content in thanks.tpl.php
 *
 * @version    $Id$
 * @package    TobbiVM-Shop
 * @copyright  Copyright (C) 2012
 * @author     Norbert Gebert
 * @license    GPL3
 */
function contentPage($refPage, $page, $subpage, $refValidate)
{
	if (isset($_POST['formsubmit']))
	{
		if ($refValidate->cleanslash($_POST['formsubmit']) === '1')
		{
			// Update the database
			$data = Array(
			'page_text' => $_POST['textx'],
			'page_lastchange' => date("Y-m-d H:i:s"),
			'page_header' => $refValidate->cleanslash($_POST['headerx']));
			db::getInstance()->where('page_name', 'thanks');

			if (db::getInstance()->update('page', $data))
				message::setNoteRow(_('The data storage was successful.'), true);
		}
	}
	db::getInstance()->where("page_name", 'thanks');
	$result = db::getInstance()->getOne("page");

	$refPage->assign('action', 'index2.php?page=' . $page . '&sub=' . $subpage);
	$refPage->assign('thanksPageHelp', help('thanks', $page, TRUE));

	$refPage->assign('pagetitel', _('Pagetitel') . ':');
	$refPage->assign('headerx', $result['page_header']);
	$refPage->assign('headerxHelp', help('header', $page));

	$refPage->assign('textx', stripslashes($result['page_text']));

	$refPage->assign('lastchange',
		_('Last change') . ': ' . date('H:i:s - d.m.Y', strtotime($result['page_lastchange'])) .
		'<input type="hidden" name="namex" value="' . $result['page_name'] . '">' .
		'<input type="hidden" name="page" value="' . $page . '">' .
		'<input type="hidden" name="subpage" value="' . $subpage . '">' .
		'<input type="hidden" name="formsubmit" value="1">');

	$refPage->assign('save', _('Save'));
	$refPage->assign('abort', _('Abort'));

	$refPage->assign('name', _('Order Completion'));
	$refPage->assign('scripts', '<script type="text/javascript" src="' . 
		'module/ckeditor/ckeditor.js"></script>');
	$refPage->addtpl('content', '/page/thanks.tpl.php');
}

?>